#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 1e5 + 5;

int n, m, L, V;
struct Node {
  int d, v, a;
} a[N];
int p[N];
void solve() {
  cin >> n >> m >> L >> V;
  rep(i, 1, n) cin >> a[i].d >> a[i].v >> a[i].a;
  rep(i, 1, m) cin >> p[i];
  sort(p + 1, p + m + 1);
  vector<pii> seg;
  rep(i, 1, n) {
    if (a[i].a > 0) {  // 加速的
      int x = a[i].d;
      if (a[i].v <= V)
        x += (V * V - a[i].v * a[i].v + a[i].a * 2) / (a[i].a * 2);
      int id = lower_bound(p + 1, p + m + 1, x) - p;
      if (id <= m) seg.push_back(pii(id, m));
    } else if (a[i].a < 0) {  // 减速的
      if (a[i].v <= V) continue;
      int l = lower_bound(p + 1, p + m + 1, a[i].d) - p;
      int x = a[i].d + (a[i].v * a[i].v - V * V - 1) / (-a[i].a * 2);
      int r = upper_bound(p + 1, p + m + 1, x) - p - 1;
      if (l <= r) seg.push_back(pii(l, r));
    } else {  // 匀速的
      if (a[i].v <= V) continue;
      int l = lower_bound(p + 1, p + m + 1, a[i].d) - p;
      if (l <= m) seg.push_back(pii(l, m));
    }
  }
  sort(seg.begin(), seg.end());
  int cnt = 0;
  int x = 0, y = 0;
  for (pii p : seg) {
    if (p.first > y)
      cnt++, x = p.first, y = p.second;
    else
      x = max(x, p.first), y = min(y, p.second);
  }
  cout << seg.size() << ' ' << m - cnt << endl;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}